﻿using RPAVIEW.views.controlLibrary;
using System.Windows;
using System.Windows.Controls;

namespace RPAVIEW.views.EditPage.flows.WriteToExcelN {
    /// <summary>
    /// Input.xaml 的交互逻辑
    /// </summary>
    public partial class Input:BaseParamViewAction{
        public Input() {
            InitializeComponent();
        }

        public override void UpdateSource() {
            this.writeObjectName.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.range.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource();
            this.row.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.column.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.writeWay.GetBindingExpression(ComboBox.SelectedIndexProperty).UpdateSource();
            this.writeContent.GetBindingExpression(SelVarTextBox.text).UpdateSource();
            this.sheetName.GetBindingExpression(SelVarTextBox.text).UpdateSource();
        }

        private void WRChanged(object sender, SelectionChangedEventArgs e) {
            int range = this.range.SelectedIndex;
            int ww = this.writeWay.SelectedIndex;
            if(range == 0) { 
                //列
                this.rowrow.Height = GridLength.Auto;
                if(ww == 0) { 
                    this.columnrow.Height = new GridLength(0);
                } else { 
                    this.columnrow.Height = GridLength.Auto;
                }
                this.writewayrow.Height = GridLength.Auto;
                this.rowLabel.Content = "起始行号";
                this.columnLabel.Content = "列名(列号)";
            }else if(range == 1) {
                //行
                if(ww == 0) { 
                    this.rowrow.Height = new GridLength(0);
                } else { 
                    this.rowrow.Height = GridLength.Auto;
                }
                this.columnrow.Height = GridLength.Auto;
                this.writewayrow.Height = GridLength.Auto;
                this.columnLabel.Content = "起始列名(列号)";
            } else { 
                //区域
                this.rowrow.Height = GridLength.Auto;
                this.columnrow.Height = GridLength.Auto;
                this.writewayrow.Height = new GridLength(0);
                this.rowLabel.Content = "起始行号";
                this.columnLabel.Content = "起始列名(列号)";
            }
        }
    }
}
